//package com.j.lemon.learn.asiainfo;
//
//import com.asiainfo.audit.beans.constant.dap.CommonConstants;
//import com.asiainfo.audit.kafka.api.apis.MessageProducer;
//import com.asiainfo.audit.kafka.api.clients.ProducerClient;
//import com.asiainfo.audit.kafka.api.configs.AisKafkaProducerConfigs;
//import org.apache.kafka.common.serialization.StringSerializer;
//
//import java.util.Properties;
//
//public class MyProducer {
//    public static void main(String[] args) throws InterruptedException {
//        System.setProperty("java.security.krb5.conf", "/Users/lijunjun/work/project/flink-job/src/main/java/flink/kafka/krb5.conf");
////        Properties properties = sendKer();
//        MessageProducer producer1 = sendKer("kerberos");
////        Producer<String, String> producer = new KafkaProducer<>(properties);
////        producer.send(new ProducerRecord<String, String>("dp_db_topic", sss));
////        producer.send(new ProducerRecord<String, String>("zy_test_topic", sss));
//        int count = 0;
////            String sss = "{\"id\":783274827691,\"op_time\":\"2022-11-24 16:11:36\",\"dp_rule_id\":672286452863729664,\"acct_pwd\":\"1\",\"acct_type\":\"1\",\"create_time\":\"2022-11-24 16:10:35\",\"duty_id\":672286452863729664,\"main_acct_name\":\"lisi"+count+"\",\"person_name\":\"zs\",\"person_org_id\":672286452863729664,\"main_acct_id\":151515,\"resource_id\":151515,\"user_mail\":\"123\",\"resource_group_path\":[123,234]}";
//            String sss = "{\"auditorId\":\"1\",\"data\":{\"716112872169537536\":{\"716112872169537536_1-duty_id\":672286452863729664,\"716112872169537536_1-acct_pwd\":\"1\",\"716112872169537536_1-dp_rule_id\":672286452863729664,\"716112872169537536_1-acct_type\":\"1\",\"716112872169537536_1-person_name\":\"zs\",\"716112872169537536_1-user_mail\":\"123\",\"716112872169537536_1-person_org_id\":672286452863729664,\"716112872169537536_1-resource_id\":151515,\"716112872169537536_1-main_acct_id\":151515,\"716112872169537536_1-op_time\":\"2022-11-24T16:11:36\",\"716112872169537536_1-create_time\":\"2022-11-24T16:10:35\",\"716112872169537536_1-id\":783274827691,\"716112872169537536_1-main_acct_name\":\"lisi10295\",\"716112872169537536_1-resource_group_path\":[123,234]}},\"tenantId\":\"1\",\"strategyId\":\"716112863759958016\"}";
//            producer1.send("kafka-ljj-test3", sss);
//            producer1.send("kafka-ljj-test3", sss);
//            producer1.send("kafka-ljj-test3", sss);
//            producer1.close();
//
//    }
//
//    // kerberos认证
//    public static MessageProducer sendKer(String auth) {
//        AisKafkaProducerConfigs aisKafkaProducerConfigs = new AisKafkaProducerConfigs();
//        aisKafkaProducerConfigs.setType("2.8.2");
//        aisKafkaProducerConfigs.setBootstarpServers("10.28.149.182:9092,10.28.149.188:9092,10.28.149.197:9092");
//        aisKafkaProducerConfigs.setRetriesConfig(3);
//        aisKafkaProducerConfigs.setBatchSizeConfig(16384);
//        aisKafkaProducerConfigs.setBufferMemoryConfig(33554432L);
//        aisKafkaProducerConfigs.setKeySerializerClassConfig(StringSerializer.class.getName());
//        aisKafkaProducerConfigs.setValueSerializerClassConfig(StringSerializer.class.getName());
//        aisKafkaProducerConfigs.setAuth(auth);
//        if(!CommonConstants.KAFKA_AUTH_NO.equals(auth)){
//            aisKafkaProducerConfigs.setSecurityProtocol("SASL_PLAINTEXT");
//            aisKafkaProducerConfigs.setSaslJaasConfig("com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab=\"/Users/lijunjun/work/project/flink-job/src/main/java/flink/kafka/kafka-client.keytab\" storeKey=true useTicketCache=false principal=\"kafka-client@AUDIT.COM\";");
//            if(CommonConstants.KAFKA_AUTH_PLAIN.equals(auth)){
//                aisKafkaProducerConfigs.setSaslMechanism("PLAIN");
//            }
//            if(CommonConstants.KAFKA_AUTH_KERBEROS.equals(auth)){
//                aisKafkaProducerConfigs.setSaslMechanism("GSSAPI");
//                aisKafkaProducerConfigs.setKrb5Path("/Users/lijunjun/work/project/flink-job/src/main/java/flink/kafka/krb5.conf");
//                aisKafkaProducerConfigs.setServiceName("kafka-server");
//            }
//        }
//
//        return ProducerClient.builder(aisKafkaProducerConfigs);
//    }
//
//
//}
